﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;

namespace RetailAnalytic.Tools.Service.Serever
{
    public partial class usrService : UserControl, RetailAnalytic.Tools.Service.Contract.InterfaceService
    {
        private ServiceHost serviceHost;
        public usrService()
        {
            InitializeComponent();
        }
        public void StartService()
        {
            try
            {
                serviceHost = new ServiceHost(typeof(usrService));
                serviceHost.Open();
            }
            catch (Exception er)
            {
                SetText(er.Message);
            }
            SetText("The service is ready.");
        }
        public void StopService()
        {
            try
            {
                serviceHost.Close();
            }
            catch (Exception er)
            {
                SetText(er.Message);
            }
            SetText("The service close.");
        }
        private void SetText(string _text)
        {
            this.richTextBox1.Text = this.richTextBox1.Text + _text + "\n";
        }
        

        #region InterfaceService Members

        public string Test(string a1, string a2)
        {
            SetText(a1 + "-----" + a2);
            return a1 + "-----" + a2;
        }

        #endregion
    }
}
